return function (conn, req, args)
  collectgarbage()

  if req.method == "PUT" then
    local rd = req.getRequestData()
    if not rd.ssid then
      dofile("server/header.lc")(conn, 400, 'json')
      rd = nil
      collectgarbage()
      return
    else
      local info = {}
      info.ap = {}
      info.ap.ssid = rd.ssid
      info.ap.pwd = rd.pwd
      info.ap.ip = rd.ip
      info.ap.netmask = rd.netmask
      info.ap.gateway = rd.gateway
      
      dofile('help/updatefile.lc')('conf/wifi.lc', info)
      info = nil
      rd = nil
      collectgarbage()
    end
  end
  
  local conf = dofile('conf/wifi.lc')
  local info = {}
  info.ssid = conf.ap.ssid or ''
  info.ip = conf.ap.ip or ''
  info.netmask = conf.ap.netmask or ''
  info.gateway = conf.ap.gateway or ''
  conf = nil

  local json = sjson.encode(info)
  if json then
    dofile("server/header.lc")(conn, 200, 'json')
    conn:send(json)
  else
    dofile("server/header.lc")(conn, 500, 'json')
  end

  json = nil
  info = nil
  collectgarbage()
end